<template>
  <div class="listContentBox ">
    <advancedQueryShrinkComponent ref="advancedQueryShrinkComponent" :labelLength="4" :queryData="queryData" @getQuery="getList" />
    <div class="listBox p-px-l-24 p-px-r-24 p-px-t-16 p-px-b-16">
      <el-row class="listBoxbtn m-px-b-16">
        <el-col :span="4">
          <el-button type="primary" add @click="handleJump('add','')">新增</el-button>
        </el-col>
      </el-row>
      <div class="listBoxTable">
        <el-table v-loading="listLoading" stripe :data="list" height="100%">
          <el-table-column label="序号" type="index" width="80" align="center" fixed="left">
            <template slot-scope="scope">
              <span>{{ pageIndex(scope.$index, queryData.queryParams) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="角色名称" prop="roleName" show-overflow-tooltip miwidth="280" />
          <el-table-column label="顺序" prop="roleSort" show-overflow-tooltip width="100" />
          <el-table-column label="状态" prop="statusLabel" show-overflow-tooltip width="100" />
          <el-table-column label="创建时间" prop="createTime" show-overflow-tooltip width="190">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" fixed="right" width="200">
            <template slot-scope="scope">
              <el-button type="text" @click="handleJump('edit',scope.row)">修改</el-button>
              <el-button type="text" typeC="danger" @click="handleDelete(scope.row)">删除</el-button>
            </template>
          </el-table-column>
          <!-- 列表缺省 -->
          <div slot="empty" class="zjm_no_data_table_list height-100 flex row-center col-center">
            <el-empty :image-size="70" description="暂无数据"></el-empty>
          </div>
        </el-table>
      </div>
      <pagination :total="listTotal" :page.sync="queryData.queryParams.pageNum" :limit.sync="queryData.queryParams.pageSize" @pagination="getList" />
    </div>
  </div>

</template>

<script>
// 混入
import { listMixins } from '@/mixins/publicMixins/listMixins'
// 组件
import advancedQueryShrinkComponent from '@/components/publicComponents/advancedQuery/indexShrink'
// ---------------------------------------------------------------------------------------
export default {
  name: 'Role',
  mixins: [listMixins],
  components: { advancedQueryShrinkComponent },
  provide() {
    return {
      listQueryParams: this
    }
  },
  data() {
    return {
      // 查询条件+查询组
      queryData: {
        queryParams: {
          pageNum: 1, // 分页的初始值
          pageSize: 10 // 每页的显示数
        },
        data: [

          {
            label: '角色名称', // 前端展示的label
            type: 'input', // 格式：input/select/date/money/number
            value: null, // 查询回填值
            valueKey: 'roleName' // 查询入参Key
          },
          {
            label: '权限字符', // 前端展示的label
            type: 'input', // 格式：input/select/date/money/number
            value: null, // 查询回填值
            valueKey: 'roleKey' // 查询入参Key
          },
          {
            label: '状态', // 前端展示的label
            type: 'select', // 格式：select
            value: null, // 查询回填值
            valueKey: 'status', // 查询入参Key
            typeData: [], // select类储存options
            dataType: 'dicts', // 获取储存options的类型  数据字典：dicts，其他接口获取：url
            getDicts: 'sys_normal_disable', // 数据字典类型值
            multiple: false// 是不是多选
          }
        ]
      }
    }
  },
  mounted() {
  },
  created() {
  },
  methods: {
    /**
    * @description: 列表
    * @Author: baoxuhui
    * @param {*} queryParams
    * @return {*}
    */
    getList(queryParams) {
      this.getListMixins('/system/role/list', queryParams)
    },
    /**
    * @description: 删除
    * @Author: baoxuhui
    * @param {*} row
    * @return {*}
    */
    handleDelete(row) {
      const url = '/system/role/removeById/' + row.roleId
      this.handleDeleteMixins(url)
    },

    /**
     * @description: 跳转
     * @Author: baoxuhui
     * @param {*} type
     * @param {*} row
     * @param {*} url
     * @return {*}
     */
    handleJump(type, row, url = '') {
      const queryParams = {}
      if (row) {
        queryParams.id = row.roleId
      }
      this.handleJumpMixins(type, queryParams, url)
    }

  }
}
</script>

